﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace DapperDemo_One.lib
{
    public static class conn工厂
    {
        public static readonly string connectionString = "Data Source=103.82.55.211;Initial Catalog=DapperTestOne;Persist Security Info=True;User ID=luchunqing;pwd=@wqw5201314!";
        public static SqlConnection GetOpenConnection(bool mars = false)
        {
            var cs = connectionString;
            if (mars)
            {
                SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder(cs) {MultipleActiveResultSets = true};
                cs = scsb.ConnectionString;
            }
            var connection = new SqlConnection(cs);
            connection.Open();
            return connection;
        }
        public static IDbConnection GetClosedConnection()
        {
            IDbConnection conn = new SqlConnection(connectionString);
            return conn;
        }
    }
}